All Questions
70 questions
3votes
2answers
242views
Leetcode 14. Longest Common Prefix beats only ~50% of C++ solutions
The task is to find the longest common prefix. While I had no trouble to find the solution, I'm interested in the statistics of my code: Runtime: 7 ms, faster than 56.36% of C++ online submissions ...
1vote
1answer
222views
Infix calculator programming challenge Kattis.com
I'm working on this C++ coding problem: Input is a sequence of up to commands, one per line, ending at end of file. Each command is a definition, a calculation, or a clear. All tokens within a ...
1vote
2answers
144views
Function wrapper that prints the result
(English) I was recently challenged to make a simple program that does the following: Function f accepts as a parameter a function g, which returns a value. Function f must return a function h which ...
4votes
3answers
385views
567: Permutation in String
I implemented a solution to the LeetCode problem: 567. Permutation in String The Problem Given two strings s1(queryStr) and s2(sourceStr), return true if s2 contains a permutation of s1, or false ...
-2votes
1answer
259views
HackerRank frequency queries
need some help or advice, HackerRank's frequency-queries challenge, the challenge of this Hackerrank problem is to check if the frequencies of number in your data structure matches the queries. small ...
1vote
1answer
274views
MSD Radix sort in Place in c++, Object/Pointer Oriented
Memory:O(log(max)base(mod)*mod)Speed:O(log(max)base(mod)*n) I did a radix sort in place to not get a auxliar array. In the process i discorver a few things. Is imposible to do LSD radix sort in place ...
4votes
2answers
3kviews
10 Kinds of People Open Kattis Problem Time Limit Exceeded C++
I am trying to solve the open kattis problem '10 kinds of people' (https://open.kattis.com/problems/10kindsofpeople) using a best-first search algorithm and c++. 10 Kinds of People The world is made ...
3votes
1answer
290views
Number of inversions on a segment
I was trying to do this question and I get TLE on one the test cases (the actual link to the question will ask you to login). What is an inversion? An inversion of an element is the number of ...
8votes
4answers
477views
Calculate sum of multiple series within array
The exercise is as follows: Player A will write list \$ a \$ consisting of \$ n \$ numbers. Player B will take a look at the paper. After that the A player will ask player B \$q\$ questions. Each ...
1vote
1answer
888views
LeetCode 809: Expressive Words
I'm posting my C++ code for LeetCode's Expressive Words. If you have time and would like to review, please do so. Thank you! Sometimes people repeat letters to represent extra feeling, such as "...
1vote
1answer
323views
LeetCode 76: Minimum Window Substring
I'm posting an sliding window problem of LeetCode (Minimum Window Substring) with C++. If you have time and would like to review the code, please do so, I appreciate that. On LeetCode, we are only ...
6votes
2answers
120views
Program for activity selection exceeds time limit
I've been trying to solve this problem for some while and the solution I have come up with exceeds the lime limit by 1-3 ms and 2 out of 10 tests get a memory issue error. Why is that? This is the ...
10votes
2answers
3kviews
Project Euler #7 10001st prime in C++
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? How can I optimize this code? ...
1vote
2answers
151views
Segmented Sieve Spoj
I tried(trying...) to solve the SPOJ prime number problem PRIME1 so i learned and implemented Segmented Sieve correctly but this program works in time for 10^8 but getting Time limit exceeded (TLE) ...
3votes
1answer
99views
(Follow-up) Project Euler #11 Largest Product in a Grid | Cache-optimized + sliding window (C++14)
Original code review: Project Euler #11 Largest Product in a Grid | Cache-optimized + sliding window (C++14) Source: HackerRank & ProjectEuler.net Problem: Largest Product in a Grid In the 20×...